import 'package:json_annotation/json_annotation.dart';

@JsonSerializable()
class TextModel {

  @JsonKey(name: 'status')
  String status;

  @JsonKey(name: 'datas')
  Datas datas;

  @JsonKey(name: 'msg')
  String msg;

  @JsonKey(name: 'code')
  int code;

  TextModel(this.status,this.datas,this.msg,this.code,);

  factory TextModel.fromJson(Map<String, dynamic> json) {
    return TextModel(
        json['status'] as String,
        json['datas'] == null ? null : Datas.fromJson(json['datas'] as Map<String, dynamic>),
        json['msg'] as String,
        json['code'] as int
    );
  }
}

@JsonSerializable()
class Datas {
  @JsonKey(name: 'show_author')
  int showAuthor;

  @JsonKey(name: 'list')
  List<TextItem> list;

  Datas(this.showAuthor, this.list);

  factory Datas.fromJson(Map<String, Object> json) {
    return Datas(
        json["show_author"] as int,
        (json["list"] as List)?.map((d) => d == null? null : TextItem.fromJson(d as Map<String, dynamic>))?.toList()
    );
  }
}

@JsonSerializable()
class TextItem{

  @JsonKey(name: 'id')
  String id;

  @JsonKey(name: 'thumbnail')
  String thumbnail;

  @JsonKey(name: 'title')
  String title;

  @JsonKey(name: 'sign')
  String sign;

  TextItem(this.id,this.thumbnail,this.title,this.sign,);

  factory TextItem.fromJson(Map<String, dynamic> json) {
    return TextItem(
        json['id'] as String, json['thumbnail'] as String,
        json['title'] as String, json['sign'] as String
    );
  }

}